package net.flashpunk.utils
{
	import com.adobe.utils.AGALMiniAssembler;
	import flash.display3D.Context3DBlendFactor;
	import flash.display3D.Context3DCompareMode;
	import flash.display3D.Context3DProgramType;
	import flash.display3D.Context3DTriangleFace;
	import flash.display3D.Program3D;
	import net.flashpunk.Entity;
	import net.flashpunk.FP;
	public class Shader
	{
		public var vertex:AGALMiniAssembler = new AGALMiniAssembler(true);
		public var fragment:AGALMiniAssembler = new AGALMiniAssembler(true);
		public var program:Program3D;
		public var blend_src:String = Context3DBlendFactor.ONE;
        public var blend_dst:String = Context3DBlendFactor.ZERO;
        public var depth_test_mode:String = Context3DCompareMode.LESS;
        public var depth_test:Boolean = true;
        public var culling_mode:String = Context3DTriangleFace.FRONT_AND_BACK;
		
		
		public static const agal_simple_vert:String = "m44 op, va0, vc0\n" + "mov v0, vc4\n";
		public static const agal_simple_frag:String = "mov oc, v0\n";
		public function Shader()
		{
			vertex.assemble(Context3DProgramType.VERTEX, agal_simple_vert);
			fragment.assemble(Context3DProgramType.FRAGMENT, agal_simple_frag);
			program = FP.context3d.createProgram();
			program.upload(vertex.agalcode, fragment.agalcode);
		}
		
		public function setup():void
		{
			 // set the render state
			FP.context3d.setBlendFactors(blend_src, blend_dst);
			FP.context3d.setDepthTest(depth_test,depth_test_mode);
            FP.context3d.setCulling(culling_mode);
			FP.context3d.setProgram(program);
		}
		
	}
}